﻿// -----------------------------------------------------------------------
// <copyright file="RemoveDisabledUsersCommandHandler.cs">
// Copyright (c) 2013 Andrey Veselov. All rights reserved.
// License:  Microsoft Public License (MS-PL)
// Contacts: http://andrey.moveax.com  andrey@moveax.com
// </copyright>
// -----------------------------------------------------------------------

namespace Moveax.DataAccess.Cqrs.Highway.EF.UnitTests.DataAccess.CommandHandlers.Users
{
	using System.Diagnostics.Contracts;
	using Moveax.DataAccess.Cqrs.Highway.EF.UnitTests.DataAccess.Database.Dto;
	using Moveax.DataAccess.Cqrs.Highway.EF.UnitTests.Model.Commands.Users;

	internal class RemoveDisabledUsersCommandHandler : ICommandHandlerSync<RemoveDisabledUsersCommand>
	{
		private readonly IRepository _repository;

		public RemoveDisabledUsersCommandHandler(IRepository repository)
		{
			Contract.Requires(repository != null);

			this._repository = repository;
		}

		public void Execute(RemoveDisabledUsersCommand command)
		{
			this._repository.Remove<UserDto>(u => u.IsDisabled);
		}
	}
}
